<!DOCTYPE html>
<html lang=zh-CN>
<head>
<meta charset=utf-8>
<title>整理修改了一个PHP的SQLite3数据库类 | Cweili Beta</title>
<meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name=description content="第一次接触 SQLite, 写得很乱, 估计也有很多错, 姑且放在这. 从 SQLiteManager 中相关代码修改而来…">
<meta property=og:type content=article>
<meta property=og:title content=整理修改了一个PHP的SQLite3数据库类>
<meta property=og:url content="http://cweili.gitcafe.com/php-sqlite3-class/">
<meta property=og:site_name content="Cweili Beta">
<meta property=og:description content="第一次接触 SQLite, 写得很乱, 估计也有很多错, 姑且放在这. 从 SQLiteManager 中相关代码修改而来…">
<meta name=twitter:card content=summary>
<meta name=twitter:title content=整理修改了一个PHP的SQLite3数据库类>
<meta name=twitter:description content="第一次接触 SQLite, 写得很乱, 估计也有很多错, 姑且放在这. 从 SQLiteManager 中相关代码修改而来…">
<link rel=alternative href=/atom.xml title="Cweili Beta" type=application/atom+xml>
<link rel=icon href=favicon.png>
<link rel=stylesheet href=//libs.baidu.com/bootstrap/3.2.0/css/bootstrap.min.css type=text/css>
<link rel=stylesheet href=../css/style.css type=text/css>
<!--[if lt IE 9]><script src="//cdn.staticfile.org/html5shiv/3.7/html5shiv.min.js" type="text/javascript"></script><![endif]-->
</head>
<body>
<div id=container>
<nav id=mobile-nav class=visible-xs>
<a href="/" class=mobile-nav-link>首页</a>
<ul class=category-list><li class=category-list-item><a class=category-list-link href=../category/学习笔记>学习笔记</a><span class=category-list-count>40</span></li><li class=category-list-item><a class=category-list-link href=../category/小生活>小生活</a><span class=category-list-count>27</span></li><li class=category-list-item><a class=category-list-link href=../category/杂物>杂物</a><span class=category-list-count>9</span></li></ul>
<a href="/tag/%E7%9B%B8%E5%86%8C/" class=mobile-nav-link>相册</a>
<a href="/about/" class=mobile-nav-link>关于</a>
<div class=clearfix></div>
</nav>
<div id=wrap>
<!--[if lt IE 9]><p class="browsehappy alert alert-danger">您正在使用一个<strong>过时</strong>的浏览器。请<a href="http://browsehappy.com/" target="_blank">更新您的浏览器</a>来达到更好的体验。</p><![endif]-->
<header id=header>
<div id=banner></div>
<div id=header-outer class=outer>
<div id=header-inner class=inner>
<nav class=main-nav>
<div id=main-nav-toggle class="nav-icon visible-xs"><i class="fa fa-bars"></i></div>
<a class="main-nav-link hidden-xs" href="/">首页</a>
</nav>
<nav id=category-nav class=hidden-xs>
<ul class=category-list><li class=category-list-item><a class=category-list-link href=../category/学习笔记>学习笔记</a><span class=category-list-count>40</span></li><li class=category-list-item><a class=category-list-link href=../category/小生活>小生活</a><span class=category-list-count>27</span></li><li class=category-list-item><a class=category-list-link href=../category/杂物>杂物</a><span class=category-list-count>9</span></li></ul>
</nav>
<nav class="main-nav hidden-xs">
<a class=main-nav-link href="/tag/%E7%9B%B8%E5%86%8C/">相册</a>
<a class=main-nav-link href="/about/">关于</a>
</nav>
<nav id=sub-nav>
<a id=nav-rss-link class="nav-icon pull-right hidden-xs" href=/atom.xml title="RSS 订阅"><i class="fa fa-rss"></i></a>
<div id=nav-search-btn class="nav-icon pull-right" title=搜索><i class="fa fa-search"></i></div>
</nav>
<div id=search-form-wrap>
<form action=http://www.baidu.com/baidu accept-charset=utf-8 class=search-form target=_blank>
<input type=search name=word class=search-form-input placeholder=搜索>
<input id=search-form-submit type=submit value=&nbsp; class=search-form-submit>
<input name=tn type=hidden value=bds>
<input name=cl type=hidden value=3>
<input name=ct type=hidden value=2097152>
<input type=hidden name=si value=cweili.gitcafe.com>
<label class=search-form-submit for=search-form-submit><i class="fa fa-search"></i></label>
</form>
</div>
</div>
<div id=header-title class=inner>
<h1 id=logo-wrap>
<a href="/" id=logo>Cweili Beta</a>
</h1>
<h2 id=subtitle-wrap>
<a href="/" id=subtitle>I&#39;m working on it</a>
</h2>
</div>
</div>
</header>
<div class=outer>
<section id=main class=col-sm-9><article id=post-php-sqlite3-class class="article article-type-post" itemscope itemprop=blogPost>
<div class=article-meta>
<a href="/php-sqlite3-class/" class=article-date>
<time datetime=2011-10-04T15:59:57.000Z itemprop=datePublished>2011-10-04</time>
</a>
<div class=article-category>
<a class=article-category-link href=../category/学习笔记>学习笔记</a>
</div>
</div>
<div class="article-inner jiathis_streak">
<header class=article-header>
<h2 class=article-title itemprop=name>
整理修改了一个PHP的SQLite3数据库类
</h2>
</header>
<div class=article-entry itemprop=articleBody>
<p> 第一次接触 SQLite, 写得很乱, 估计也有很多错, 姑且放在这.<br> 从 SQLiteManager 中相关代码修改而来…<br><a id=more></a></p>
<figure class="highlight php"><table><tr><td class=gutter><pre><div class=line>1</div><div class=line>2</div><div class=line>3</div><div class=line>4</div><div class=line>5</div><div class=line>6</div><div class=line>7</div><div class=line>8</div><div class=line>9</div><div class=line>10</div><div class=line>11</div><div class=line>12</div><div class=line>13</div><div class=line>14</div><div class=line>15</div><div class=line>16</div><div class=line>17</div><div class=line>18</div><div class=line>19</div><div class=line>20</div><div class=line>21</div><div class=line>22</div><div class=line>23</div><div class=line>24</div><div class=line>25</div><div class=line>26</div><div class=line>27</div><div class=line>28</div><div class=line>29</div><div class=line>30</div><div class=line>31</div><div class=line>32</div><div class=line>33</div><div class=line>34</div><div class=line>35</div><div class=line>36</div><div class=line>37</div><div class=line>38</div><div class=line>39</div><div class=line>40</div><div class=line>41</div><div class=line>42</div><div class=line>43</div><div class=line>44</div><div class=line>45</div><div class=line>46</div><div class=line>47</div><div class=line>48</div><div class=line>49</div><div class=line>50</div><div class=line>51</div><div class=line>52</div><div class=line>53</div><div class=line>54</div><div class=line>55</div><div class=line>56</div><div class=line>57</div><div class=line>58</div><div class=line>59</div><div class=line>60</div><div class=line>61</div><div class=line>62</div><div class=line>63</div><div class=line>64</div><div class=line>65</div><div class=line>66</div><div class=line>67</div><div class=line>68</div><div class=line>69</div><div class=line>70</div><div class=line>71</div><div class=line>72</div><div class=line>73</div><div class=line>74</div><div class=line>75</div><div class=line>76</div><div class=line>77</div><div class=line>78</div><div class=line>79</div><div class=line>80</div><div class=line>81</div><div class=line>82</div><div class=line>83</div><div class=line>84</div><div class=line>85</div><div class=line>86</div><div class=line>87</div><div class=line>88</div><div class=line>89</div><div class=line>90</div><div class=line>91</div><div class=line>92</div><div class=line>93</div><div class=line>94</div><div class=line>95</div><div class=line>96</div><div class=line>97</div><div class=line>98</div><div class=line>99</div><div class=line>100</div><div class=line>101</div><div class=line>102</div><div class=line>103</div><div class=line>104</div><div class=line>105</div><div class=line>106</div><div class=line>107</div><div class=line>108</div><div class=line>109</div><div class=line>110</div><div class=line>111</div><div class=line>112</div><div class=line>113</div><div class=line>114</div><div class=line>115</div><div class=line>116</div><div class=line>117</div><div class=line>118</div><div class=line>119</div><div class=line>120</div><div class=line>121</div><div class=line>122</div><div class=line>123</div><div class=line>124</div><div class=line>125</div><div class=line>126</div><div class=line>127</div><div class=line>128</div><div class=line>129</div><div class=line>130</div><div class=line>131</div><div class=line>132</div><div class=line>133</div><div class=line>134</div><div class=line>135</div><div class=line>136</div><div class=line>137</div><div class=line>138</div><div class=line>139</div><div class=line>140</div><div class=line>141</div><div class=line>142</div><div class=line>143</div><div class=line>144</div><div class=line>145</div><div class=line>146</div><div class=line>147</div><div class=line>148</div><div class=line>149</div><div class=line>150</div><div class=line>151</div><div class=line>152</div><div class=line>153</div><div class=line>154</div><div class=line>155</div><div class=line>156</div><div class=line>157</div><div class=line>158</div><div class=line>159</div><div class=line>160</div><div class=line>161</div><div class=line>162</div><div class=line>163</div><div class=line>164</div><div class=line>165</div><div class=line>166</div><div class=line>167</div><div class=line>168</div><div class=line>169</div><div class=line>170</div><div class=line>171</div><div class=line>172</div><div class=line>173</div><div class=line>174</div><div class=line>175</div><div class=line>176</div><div class=line>177</div><div class=line>178</div><div class=line>179</div><div class=line>180</div><div class=line>181</div><div class=line>182</div><div class=line>183</div><div class=line>184</div><div class=line>185</div><div class=line>186</div><div class=line>187</div><div class=line>188</div><div class=line>189</div><div class=line>190</div><div class=line>191</div><div class=line>192</div><div class=line>193</div><div class=line>194</div><div class=line>195</div><div class=line>196</div><div class=line>197</div><div class=line>198</div><div class=line>199</div><div class=line>200</div><div class=line>201</div><div class=line>202</div><div class=line>203</div><div class=line>204</div><div class=line>205</div><div class=line>206</div><div class=line>207</div><div class=line>208</div><div class=line>209</div><div class=line>210</div><div class=line>211</div><div class=line>212</div><div class=line>213</div><div class=line>214</div><div class=line>215</div><div class=line>216</div><div class=line>217</div><div class=line>218</div><div class=line>219</div><div class=line>220</div><div class=line>221</div><div class=line>222</div><div class=line>223</div><div class=line>224</div><div class=line>225</div><div class=line>226</div><div class=line>227</div><div class=line>228</div><div class=line>229</div><div class=line>230</div><div class=line>231</div><div class=line>232</div><div class=line>233</div><div class=line>234</div><div class=line>235</div><div class=line>236</div><div class=line>237</div><div class=line>238</div><div class=line>239</div><div class=line>240</div><div class=line>241</div><div class=line>242</div><div class=line>243</div><div class=line>244</div><div class=line>245</div><div class=line>246</div><div class=line>247</div><div class=line>248</div><div class=line>249</div><div class=line>250</div><div class=line>251</div><div class=line>252</div><div class=line>253</div><div class=line>254</div><div class=line>255</div><div class=line>256</div><div class=line>257</div><div class=line>258</div><div class=line>259</div><div class=line>260</div><div class=line>261</div><div class=line>262</div><div class=line>263</div><div class=line>264</div><div class=line>265</div><div class=line>266</div><div class=line>267</div><div class=line>268</div><div class=line>269</div><div class=line>270</div><div class=line>271</div><div class=line>272</div><div class=line>273</div><div class=line>274</div><div class=line>275</div><div class=line>276</div><div class=line>277</div><div class=line>278</div><div class=line>279</div><div class=line>280</div><div class=line>281</div><div class=line>282</div><div class=line>283</div><div class=line>284</div><div class=line>285</div><div class=line>286</div><div class=line>287</div><div class=line>288</div><div class=line>289</div><div class=line>290</div><div class=line>291</div><div class=line>292</div><div class=line>293</div><div class=line>294</div><div class=line>295</div><div class=line>296</div><div class=line>297</div><div class=line>298</div><div class=line>299</div><div class=line>300</div><div class=line>301</div><div class=line>302</div><div class=line>303</div><div class=line>304</div><div class=line>305</div><div class=line>306</div><div class=line>307</div><div class=line>308</div><div class=line>309</div><div class=line>310</div><div class=line>311</div><div class=line>312</div><div class=line>313</div><div class=line>314</div><div class=line>315</div><div class=line>316</div><div class=line>317</div><div class=line>318</div><div class=line>319</div><div class=line>320</div><div class=line>321</div><div class=line>322</div><div class=line>323</div><div class=line>324</div><div class=line>325</div><div class=line>326</div><div class=line>327</div><div class=line>328</div><div class=line>329</div><div class=line>330</div><div class=line>331</div><div class=line>332</div><div class=line>333</div><div class=line>334</div><div class=line>335</div><div class=line>336</div><div class=line>337</div><div class=line>338</div><div class=line>339</div><div class=line>340</div><div class=line>341</div><div class=line>342</div><div class=line>343</div><div class=line>344</div><div class=line>345</div><div class=line>346</div><div class=line>347</div><div class=line>348</div><div class=line>349</div><div class=line>350</div><div class=line>351</div><div class=line>352</div><div class=line>353</div><div class=line>354</div><div class=line>355</div><div class=line>356</div><div class=line>357</div><div class=line>358</div><div class=line>359</div><div class=line>360</div><div class=line>361</div><div class=line>362</div><div class=line>363</div><div class=line>364</div><div class=line>365</div><div class=line>366</div><div class=line>367</div><div class=line>368</div><div class=line>369</div><div class=line>370</div><div class=line>371</div><div class=line>372</div><div class=line>373</div><div class=line>374</div><div class=line>375</div><div class=line>376</div><div class=line>377</div><div class=line>378</div><div class=line>379</div><div class=line>380</div><div class=line>381</div><div class=line>382</div><div class=line>383</div><div class=line>384</div><div class=line>385</div><div class=line>386</div><div class=line>387</div><div class=line>388</div><div class=line>389</div><div class=line>390</div><div class=line>391</div><div class=line>392</div><div class=line>393</div><div class=line>394</div><div class=line>395</div><div class=line>396</div><div class=line>397</div><div class=line>398</div><div class=line>399</div></pre></td><td class=code><pre><div class=line><span class=preprocessor>&lt;?php</span></div><div class=line>define(<span class=string>'DEBUG'</span>, <span class=keyword>true</span>);</div><div class=line><span class=keyword>if</span>(!defined(<span class=string>'PDO_ATTR_TIMEOUT'</span>) ) 		define(<span class=string>'PDO_ATTR_TIMEOUT'</span>, 		PDO::ATTR_TIMEOUT);</div><div class=line><span class=keyword>if</span>(!defined(<span class=string>'PDO_FETCH_ASSOC'</span>) ) 		define(<span class=string>'PDO_FETCH_ASSOC'</span>, 		PDO::FETCH_ASSOC);</div><div class=line><span class=keyword>if</span>(!defined(<span class=string>'PDO_FETCH_NUM'</span>) ) 		define(<span class=string>'PDO_FETCH_NUM'</span>, 		PDO::FETCH_NUM);</div><div class=line><span class=keyword>if</span>(!defined(<span class=string>'PDO_FETCH_BOTH'</span>) ) 		define(<span class=string>'PDO_FETCH_BOTH'</span>, 		PDO::FETCH_BOTH);</div><div class=line><span class=keyword>if</span>(!defined(<span class=string>'PDO_ATTR_PERSISTENT'</span>) ) 	define(<span class=string>'PDO_ATTR_PERSISTENT'</span>, 	PDO::ATTR_PERSISTENT);</div><div class=line><span class=keyword>if</span>(!defined(<span class=string>'PDO_ATTR_CASE'</span>) ) 		define(<span class=string>'PDO_ATTR_CASE'</span>, 		PDO::ATTR_CASE);</div><div class=line><span class=keyword>if</span>(!defined(<span class=string>'PDO_CASE_NATURAL'</span>) ) 		define(<span class=string>'PDO_CASE_NATURAL'</span>, 		PDO::CASE_NATURAL);</div><div class=line><span class=keyword>if</span>(!defined(<span class=string>'PDO_ATTR_AUTOCOMMIT'</span>) ) 	define(<span class=string>'PDO_ATTR_AUTOCOMMIT'</span>, 	PDO::ATTR_AUTOCOMMIT);</div><div class=line><span class=keyword>if</span>(!defined(<span class=string>'PDO_ATTR_ERRMODE'</span>) ) 		define(<span class=string>'PDO_ATTR_ERRMODE'</span>, 		PDO::ATTR_ERRMODE);</div><div class=line><span class=keyword>if</span>(!defined(<span class=string>'PDO_ERRMODE_EXCEPTION'</span>) ) define(<span class=string>'PDO_ERRMODE_EXCEPTION'</span>, PDO::ERRMODE_EXCEPTION);</div><div class=line><span class=keyword>if</span>(!defined(<span class=string>'PDO_ERRMODE_SILENT'</span>) ) 	define(<span class=string>'PDO_ERRMODE_SILENT'</span>, 	PDO::ERRMODE_SILENT);</div><div class=line></div><div class=line><span class=keyword>if</span>(!defined(<span class=string>'SQLITE_BOTH'</span>) ) 	define(<span class=string>'SQLITE_BOTH'</span>, 	PDO_FETCH_BOTH);</div><div class=line><span class=keyword>if</span>(!defined(<span class=string>'SQLITE_ASSOC'</span>) ) 	define(<span class=string>'SQLITE_ASSOC'</span>, 	PDO_FETCH_ASSOC);</div><div class=line><span class=keyword>if</span>(!defined(<span class=string>'SQLITE_NUM'</span>) ) 	define(<span class=string>'SQLITE_NUM'</span>, 	PDO_FETCH_NUM);</div><div class=line></div><div class=line><span class=class><span class=keyword>class</span> <span class=title>db_connect</span> </span>{</div><div class=line></div><div class=line>	<span class=keyword>var</span> <span class=variable>$dbPath</span>;</div><div class=line>	<span class=keyword>var</span> <span class=variable>$connId</span>;</div><div class=line>	<span class=keyword>var</span> <span class=variable>$error</span>;</div><div class=line>	<span class=keyword>var</span> <span class=variable>$errorMessage</span>;</div><div class=line>	<span class=keyword>var</span> <span class=variable>$readOnly</span>;</div><div class=line>	<span class=keyword>var</span> <span class=variable>$resId</span>;</div><div class=line>	<span class=keyword>var</span> <span class=variable>$dbVersion</span>;</div><div class=line>	<span class=keyword>var</span> <span class=variable>$querynum</span> = <span class=number>0</span>;</div><div class=line>	<span class=keyword>var</span> <span class=variable>$querytext</span> = <span class=keyword>array</span>();</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>db_connect</span><span class=params>(<span class=variable>$dbPath</span>)</span> </span>{</div><div class=line>		<span class=variable>$this</span><span class=variable>-&gt;dbPath</span> = <span class=variable>$dbPath</span>;</div><div class=line>		<span class=variable>$this</span><span class=variable>-&gt;dbVersion</span> = <span class=number>3</span>;</div><div class=line>		<span class=keyword>if</span>(<span class=variable>$dbPath</span> == <span class=string>':memory:'</span>) {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;readOnly</span> = <span class=keyword>false</span>;			</div><div class=line>		} <span class=keyword>else</span> {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;readOnly</span> = !is_writable(<span class=variable>$dbPath</span>);</div><div class=line>		} </div><div class=line>		<span class=comment>//parent::sqlite($dbPath);</span></div><div class=line>		<span class=keyword>if</span>(class_exists(<span class=string>'PDO'</span>) && <span class=variable>$this</span><span class=variable>-&gt;connect</span>(<span class=variable>$dbPath</span>)) {</div><div class=line>			<span class=keyword>return</span> <span class=variable>$this</span><span class=variable>-&gt;connId</span>;</div><div class=line>		} <span class=keyword>else</span> {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;getError</span>();</div><div class=line>			<span class=keyword>return</span> <span class=keyword>false</span>;</div><div class=line>		}</div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>isReadOnly</span><span class=params>()</span> </span>{</div><div class=line>		<span class=keyword>return</span> <span class=variable>$this</span><span class=variable>-&gt;readOnly</span>;</div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>getVersion</span><span class=params>()</span> </span>{</div><div class=line>		<span class=keyword>return</span> <span class=variable>$this</span><span class=variable>-&gt;dbVersion</span>;</div><div class=line>	}</div><div class=line></div><div class=line>   <span class=function><span class=keyword>function</span> <span class=title>getConnId</span><span class=params>()</span> </span>{</div><div class=line>		<span class=keyword>if</span>(is_resource(<span class=variable>$this</span><span class=variable>-&gt;connId</span>) || is_object(<span class=variable>$this</span><span class=variable>-&gt;connId</span>)) {</div><div class=line>			<span class=keyword>return</span> <span class=variable>$this</span><span class=variable>-&gt;connId</span>;</div><div class=line>		} <span class=keyword>else</span> {</div><div class=line>			<span class=keyword>return</span> <span class=keyword>false</span>;</div><div class=line>		}</div><div class=line>	} </div><div class=line></div><div class=line>	<span class=comment>/*function escape($string) {</span></div><div class=line>		if(function_exists('sqlite_escape_string')) {</div><div class=line>			$res = sqlite_escape_string($string);</div><div class=line>		} else {</div><div class=line>			$res = str_replace("'","''", $string);</div><div class=line>		}</div><div class=line>		return $res;</div><div class=line>	}	*/</div><div class=line></div><div class=line>	<span class=comment>/**</span></div><div class=line>	 * Get version number of SQLite database file</div><div class=line>	 *</div><div class=line>	 *<span class=phpdoc> @param</span> string $fullPath full path with filename of the database file</div><div class=line>	 *<span class=phpdoc> @return</span> version number or false</div><div class=line>	 */</div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>getDbVersion</span><span class=params>(<span class=variable>$fullPath</span>)</span></span>{</div><div class=line>		<span class=keyword>if</span>(!file_exists(<span class=variable>$fullPath</span>)) <span class=variable>$fullPath</span> = DEFAULT_DB_PATH . <span class=variable>$fullPath</span>;</div><div class=line>		<span class=variable>$fp</span> = @fopen(<span class=variable>$fullPath</span>, <span class=string>'r'</span>);</div><div class=line>		<span class=keyword>if</span> (<span class=variable>$fp</span>){</div><div class=line>			<span class=variable>$signature</span> = fread(<span class=variable>$fp</span>, <span class=number>47</span>);</div><div class=line>			<span class=keyword>if</span>(<span class=variable>$signature</span> == <span class=string>"** This file contains an SQLite 2.1 database **"</span>) <span class=variable>$dbVersion</span> = <span class=number>2</span>;</div><div class=line>			<span class=keyword>elseif</span>(substr(<span class=variable>$signature</span>, <span class=number>0</span>, <span class=number>15</span>) == <span class=string>"SQLite format 3"</span>) <span class=variable>$dbVersion</span> = <span class=number>3</span>;</div><div class=line>			<span class=keyword>else</span> <span class=variable>$dbVersion</span> = <span class=keyword>false</span>;</div><div class=line>			fclose(<span class=variable>$fp</span>);</div><div class=line>			<span class=keyword>return</span> <span class=variable>$dbVersion</span>;</div><div class=line>		}</div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>connect</span><span class=params>(<span class=variable>$dbPath</span>)</span> </span>{</div><div class=line>		<span class=keyword>try</span> {</div><div class=line>			<span class=variable>$user</span> = <span class=string>''</span>;</div><div class=line>			<span class=variable>$password</span> = <span class=string>''</span>;</div><div class=line>			<span class=variable>$arrayAttrib</span> = <span class=keyword>array</span>();</div><div class=line>			<span class=keyword>if</span>(<span class=variable>$dbPath</span> == <span class=string>':memory:'</span>) <span class=variable>$arrayAttrib</span>[PDO_ATTR_PERSISTENT] = <span class=keyword>true</span>;</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;connId</span> = <span class=keyword>new</span> PDO(<span class=string>'sqlite:'</span>.<span class=variable>$dbPath</span>, <span class=variable>$user</span>, <span class=variable>$password</span>, <span class=variable>$arrayAttrib</span>); </div><div class=line></div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;connId</span><span class=variable>-&gt;setAttribute</span>(PDO_ATTR_CASE, PDO_CASE_NATURAL);</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;connId</span><span class=variable>-&gt;query</span>(<span class=string>"PRAGMA count_changes=1;"</span>);</div><div class=line>		} <span class=keyword>catch</span> (PDOException <span class=variable>$e</span>) {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;error</span> = <span class=keyword>true</span>;</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;errorMessage</span> = <span class=variable>$e</span><span class=variable>-&gt;getMessage</span>();</div><div class=line>			<span class=keyword>return</span> <span class=keyword>false</span>;</div><div class=line>		}</div><div class=line>		<span class=keyword>if</span>(DEBUG) {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;connId</span><span class=variable>-&gt;setAttribute</span>(PDO_ATTR_ERRMODE, PDO_ERRMODE_EXCEPTION);</div><div class=line>		} <span class=keyword>else</span> {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;connId</span><span class=variable>-&gt;setAttribute</span>(PDO_ATTR_ERRMODE, PDO_ERRMODE_SILENT);</div><div class=line>		}</div><div class=line>		<span class=keyword>return</span> <span class=variable>$this</span><span class=variable>-&gt;connId</span>;</div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>getError</span><span class=params>(<span class=variable>$errorCode</span> = null)</span> </span>{</div><div class=line>		<span class=keyword>if</span>(is_resource(<span class=variable>$this</span><span class=variable>-&gt;resId</span>)) {</div><div class=line>			<span class=variable>$errorInfo</span> = <span class=variable>$this</span><span class=variable>-&gt;resId</span><span class=variable>-&gt;errorInfo</span>();</div><div class=line>		} <span class=keyword>else</span> {</div><div class=line>			<span class=variable>$errorInfo</span> = <span class=variable>$this</span><span class=variable>-&gt;connId</span><span class=variable>-&gt;errorInfo</span>();</div><div class=line>		}</div><div class=line>		<span class=keyword>if</span>(is_array(<span class=variable>$errorInfo</span>) && <span class=keyword>isset</span>(<span class=variable>$errorInfo</span>[<span class=number>2</span>])) {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;error</span> = <span class=keyword>true</span>;</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;errorMessage</span> = <span class=variable>$errorInfo</span>[<span class=number>2</span>];</div><div class=line>		} <span class=keyword>else</span> {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;errorMessage</span> = <span class=string>'not an error'</span>;</div><div class=line>		}</div><div class=line>		<span class=keyword>return</span> <span class=variable>$this</span><span class=variable>-&gt;errorMessage</span>;</div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>getErrorMessage</span><span class=params>()</span> </span>{</div><div class=line>		<span class=keyword>return</span> <span class=variable>$this</span><span class=variable>-&gt;errorMessage</span>;</div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>escape</span><span class=params>(<span class=variable>$string</span>)</span> </span>{</div><div class=line>		<span class=keyword>if</span>(function_exists(<span class=string>'sqlite_escape_string'</span>)) {</div><div class=line>			<span class=variable>$res</span> = sqlite_escape_string(<span class=variable>$string</span>);</div><div class=line>		} <span class=keyword>else</span> {</div><div class=line>			<span class=variable>$res</span> = str_replace(<span class=string>"'"</span>, <span class=string>"''"</span>, <span class=variable>$string</span>);</div><div class=line>		}</div><div class=line>		<span class=keyword>return</span> <span class=variable>$res</span>;</div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>query</span><span class=params>(<span class=variable>$sqlString</span>, <span class=variable>$buffered</span> = true, <span class=variable>$assign</span> = true)</span> </span>{</div><div class=line>		<span class=variable>$sqlString</span> = str_replace(<span class=string>"\r\n"</span>, <span class=string>"\n"</span>, <span class=variable>$sqlString</span>);</div><div class=line>		<span class=variable>$sqlString</span> = ereg_replace(<span class=string>"/;?\n/"</span>, <span class=string>";\n"</span>, <span class=variable>$sqlString</span>);</div><div class=line>		<span class=comment>//$sqlString = str_replace("\\'", "''", $sqlString);</span></div><div class=line>		<span class=variable>$sqlString</span> = preg_replace(<span class=string>"/^use.*\n/i"</span>, <span class=string>''</span>, <span class=variable>$sqlString</span>);</div><div class=line>		<span class=keyword>if</span>(strpos(<span class=variable>$sqlString</span>, <span class=string>";\n"</span>)){</div><div class=line>			<span class=comment>/*$tabQuery = explode(";\n", $sqlString);</span></div><div class=line>			foreach($tabQuery as $req) {</div><div class=line>				if(empty($req)) continue;</div><div class=line>				$this-&gt;query_once($req, $buffered, $assign);</div><div class=line>			}*/</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;connId</span><span class=variable>-&gt;exec</span>(<span class=variable>$sqlString</span>);</div><div class=line>		} <span class=keyword>else</span> {</div><div class=line>			<span class=keyword>return</span> <span class=variable>$this</span><span class=variable>-&gt;query_once</span>(<span class=variable>$sqlString</span>, <span class=variable>$buffered</span>, <span class=variable>$assign</span>);</div><div class=line>		}</div><div class=line></div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>query_once</span><span class=params>(<span class=variable>$sqlString</span>, <span class=variable>$buffered</span> = true, <span class=variable>$assign</span> = true)</span> </span>{</div><div class=line>		<span class=keyword>try</span> {</div><div class=line>			<span class=keyword>if</span>(<span class=variable>$assign</span> && is_object(<span class=variable>$this</span><span class=variable>-&gt;resId</span>)) <span class=variable>$this</span><span class=variable>-&gt;resId</span><span class=variable>-&gt;closeCursor</span>();</div><div class=line>			<span class=keyword>if</span>(substr(trim(<span class=variable>$sqlString</span>), -<span class=number>1</span>) != <span class=string>';'</span>) <span class=variable>$sqlString</span> .= <span class=string>';'</span>;</div><div class=line>			<span class=keyword>if</span>(DEBUG) <span class=variable>$resId</span> = <span class=variable>$this</span><span class=variable>-&gt;connId</span><span class=variable>-&gt;query</span>(<span class=variable>$sqlString</span>);</div><div class=line>			<span class=keyword>else</span> <span class=variable>$resId</span> = @<span class=variable>$this</span><span class=variable>-&gt;connId</span><span class=variable>-&gt;query</span>(<span class=variable>$sqlString</span>);</div><div class=line>			<span class=keyword>if</span>(<span class=variable>$assign</span>) <span class=variable>$this</span><span class=variable>-&gt;resId</span> = <span class=variable>$resId</span>;</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;querytext</span>[<span class=variable>$this</span><span class=variable>-&gt;querynum</span>] = <span class=variable>$sqlString</span>;</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;querynum</span>++;</div><div class=line></div><div class=line>		} <span class=keyword>catch</span>(PDOException <span class=variable>$e</span>) {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;error</span> = <span class=keyword>true</span>;</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;errorMessage</span> = <span class=variable>$e</span><span class=variable>-&gt;getMessage</span>();</div><div class=line>			<span class=keyword>return</span> <span class=keyword>false</span>; </div><div class=line>		}</div><div class=line>		<span class=variable>$tempErrorInfo</span> = <span class=variable>$this</span><span class=variable>-&gt;connId</span><span class=variable>-&gt;errorInfo</span>();</div><div class=line>		<span class=keyword>if</span>(is_array(<span class=variable>$tempErrorInfo</span>) && <span class=keyword>isset</span>(<span class=variable>$tempErrorInfo</span>[<span class=number>0</span>]) && (<span class=variable>$tempErrorInfo</span>[<span class=number>0</span>] != <span class=string>'00000'</span>)) {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;error</span> = <span class=keyword>true</span>;</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;errorMessage</span> = <span class=variable>$tempErrorInfo</span>[<span class=number>2</span>];</div><div class=line>			<span class=keyword>return</span> <span class=keyword>false</span>;</div><div class=line>		}</div><div class=line>		<span class=keyword>return</span> <span class=variable>$resId</span>;</div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>array_query</span><span class=params>(<span class=variable>$sqlString</span>, <span class=variable>$result_type</span>=SQLITE_BOTH, <span class=variable>$decode_binary</span>=true)</span> </span>{</div><div class=line>		<span class=keyword>try</span> {</div><div class=line>			<span class=variable>$result_type</span> = <span class=variable>$this</span><span class=variable>-&gt;convertResultType</span>(<span class=variable>$result_type</span>);</div><div class=line>			<span class=variable>$q</span> = <span class=variable>$this</span><span class=variable>-&gt;query_once</span>(<span class=variable>$sqlString</span>); </div><div class=line>			<span class=variable>$rows</span> = <span class=variable>$q</span><span class=variable>-&gt;fetchAll</span>(<span class=variable>$result_type</span>);</div><div class=line>		} <span class=keyword>catch</span>(PDOException <span class=variable>$e</span>) {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;error</span> = <span class=keyword>true</span>;</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;errorMessage</span> = <span class=variable>$e</span><span class=variable>-&gt;getMessage</span>();</div><div class=line>			<span class=keyword>return</span> <span class=keyword>false</span>; </div><div class=line>		}</div><div class=line>		<span class=keyword>return</span> <span class=variable>$rows</span>;</div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>num_rows</span><span class=params>(<span class=variable>$resId</span> = null)</span> </span>{</div><div class=line>		<span class=comment>/*try {</span></div><div class=line>			if($resId == null) $resId = $this-&gt;resId;</div><div class=line>			if(DEBUG) $out = $resId-&gt;rowCount();</div><div class=line>			else $out =  @$resId-&gt;rowCount();</div><div class=line>		} catch(PDOException $e) {*/</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;error</span> = <span class=keyword>true</span>;</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;errorMessage</span> = <span class=string>'[SQLITE3] Don\'t support num_rows'</span>;<span class=comment>//$e-&gt;getMessage();</span></div><div class=line>			<span class=keyword>return</span> <span class=keyword>false</span>; </div><div class=line>		<span class=comment>//}</span></div><div class=line>		<span class=comment>//return $out;</span></div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>fetch_single</span><span class=params>(<span class=variable>$resId</span>=null, <span class=variable>$result_type</span>=SQLITE_BOTH)</span> </span>{</div><div class=line>		<span class=keyword>try</span> {</div><div class=line>			<span class=variable>$result_type</span> = <span class=variable>$this</span><span class=variable>-&gt;convertResultType</span>(<span class=variable>$result_type</span>);</div><div class=line>			<span class=keyword>if</span>(<span class=variable>$resId</span> == <span class=keyword>null</span>) <span class=variable>$resId</span> = <span class=variable>$this</span><span class=variable>-&gt;resId</span>;</div><div class=line>			<span class=keyword>if</span>(DEBUG) <span class=variable>$out</span> =  <span class=variable>$resId</span><span class=variable>-&gt;fetchColumn</span>();</div><div class=line>			<span class=keyword>else</span> <span class=variable>$out</span> =  @<span class=variable>$resId</span><span class=variable>-&gt;fetchColumn</span>();</div><div class=line>		} <span class=keyword>catch</span>(PDOException <span class=variable>$e</span>) {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;error</span> = <span class=keyword>true</span>;</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;errorMessage</span> = <span class=variable>$e</span><span class=variable>-&gt;getMessage</span>();</div><div class=line>			<span class=keyword>return</span> <span class=keyword>false</span>; </div><div class=line>		}</div><div class=line>		<span class=keyword>return</span> <span class=variable>$out</span>;</div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>fetch_first</span><span class=params>(<span class=variable>$sqlString</span>, <span class=variable>$result_type</span>=SQLITE_BOTH)</span> </span>{</div><div class=line>		<span class=keyword>return</span> <span class=variable>$this</span><span class=variable>-&gt;fetch_single</span>(<span class=variable>$this</span><span class=variable>-&gt;query_once</span>(<span class=variable>$sqlString</span>), <span class=variable>$result_type</span>);</div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>result_first</span><span class=params>(<span class=variable>$sqlString</span>, <span class=variable>$result_type</span>=SQLITE_BOTH)</span> </span>{</div><div class=line>		<span class=keyword>return</span> <span class=variable>$this</span><span class=variable>-&gt;fetch_single</span>(<span class=variable>$this</span><span class=variable>-&gt;query_once</span>(<span class=variable>$sqlString</span>), <span class=variable>$result_type</span>);</div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>fetch_array</span><span class=params>(<span class=variable>$resId</span>=null, <span class=variable>$result_type</span>=SQLITE_BOTH, <span class=variable>$decode_binary</span>=true)</span> </span>{</div><div class=line>		<span class=keyword>try</span> {</div><div class=line>			<span class=variable>$result_type</span> = <span class=variable>$this</span><span class=variable>-&gt;convertResultType</span>(<span class=variable>$result_type</span>);</div><div class=line>			<span class=keyword>if</span>(<span class=variable>$resId</span> == <span class=keyword>null</span>) <span class=variable>$resId</span> = <span class=variable>$this</span><span class=variable>-&gt;resId</span>;</div><div class=line>			<span class=keyword>if</span>(DEBUG) <span class=variable>$out</span> =  <span class=variable>$resId</span><span class=variable>-&gt;fetch</span>(<span class=variable>$result_type</span>);</div><div class=line>			<span class=keyword>else</span> <span class=variable>$out</span> =  @<span class=variable>$resId</span><span class=variable>-&gt;fetch</span>(<span class=variable>$result_type</span>);</div><div class=line>		} <span class=keyword>catch</span>(PDOException <span class=variable>$e</span>) {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;error</span> = <span class=keyword>true</span>;</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;errorMessage</span> = <span class=variable>$e</span><span class=variable>-&gt;getMessage</span>();</div><div class=line>			<span class=keyword>return</span> <span class=keyword>false</span>; </div><div class=line>		}</div><div class=line>		<span class=keyword>return</span> <span class=variable>$out</span>;</div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>fetch_row</span><span class=params>(<span class=variable>$resId</span>=null, <span class=variable>$result_type</span>=SQLITE_BOTH, <span class=variable>$decode_binary</span>=true)</span> </span>{</div><div class=line>		<span class=keyword>return</span> <span class=variable>$this</span><span class=variable>-&gt;fetch_array</span>(<span class=variable>$resId</span>, <span class=variable>$result_type</span>, <span class=variable>$decode_binary</span>);</div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>last_insert_id</span><span class=params>()</span> </span>{</div><div class=line>		<span class=keyword>try</span> {</div><div class=line>			<span class=keyword>if</span>(DEBUG) <span class=variable>$out</span> = <span class=variable>$this</span><span class=variable>-&gt;connId</span><span class=variable>-&gt;lastInsertId</span>();</div><div class=line>			<span class=keyword>else</span> <span class=variable>$out</span> = @<span class=variable>$this</span><span class=variable>-&gt;connId</span><span class=variable>-&gt;lastInsertId</span>();</div><div class=line>		} <span class=keyword>catch</span>(PDOException <span class=variable>$e</span>) {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;error</span> = <span class=keyword>true</span>;</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;errorMessage</span> = <span class=variable>$e</span><span class=variable>-&gt;getMessage</span>();</div><div class=line>			<span class=keyword>return</span> <span class=keyword>false</span>; </div><div class=line>		}</div><div class=line>		<span class=keyword>return</span> <span class=variable>$out</span>;	</div><div class=line>	}	</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>changes</span><span class=params>(<span class=variable>$resId</span> = null)</span> </span>{</div><div class=line>		<span class=keyword>try</span> {</div><div class=line>			<span class=keyword>if</span>(<span class=variable>$resId</span> == <span class=keyword>null</span>) <span class=variable>$resId</span> = <span class=variable>$this</span><span class=variable>-&gt;resId</span>;			</div><div class=line>			<span class=keyword>if</span>(is_object(<span class=variable>$resId</span>)) <span class=variable>$out</span> = <span class=variable>$this</span><span class=variable>-&gt;num_rows</span>(<span class=variable>$resId</span>);</div><div class=line>			<span class=keyword>else</span> <span class=variable>$out</span> = <span class=number>0</span>;</div><div class=line>		} <span class=keyword>catch</span>(PDOException <span class=variable>$e</span>) {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;error</span> = <span class=keyword>true</span>;</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;errorMessage</span> = <span class=variable>$e</span><span class=variable>-&gt;getMessage</span>();</div><div class=line>			<span class=keyword>return</span> <span class=keyword>false</span>; </div><div class=line>		}</div><div class=line>		<span class=keyword>return</span> <span class=variable>$out</span>;</div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>num_fields</span><span class=params>(<span class=variable>$resId</span> = null)</span> </span>{</div><div class=line>		<span class=keyword>try</span> {</div><div class=line>			<span class=keyword>if</span>(<span class=variable>$resId</span> == <span class=keyword>null</span>) <span class=variable>$resId</span> = <span class=variable>$this</span><span class=variable>-&gt;resId</span>;</div><div class=line>			<span class=keyword>if</span>(DEBUG) <span class=variable>$out</span> =  <span class=variable>$resId</span><span class=variable>-&gt;columnCount</span>();</div><div class=line>			<span class=keyword>else</span> <span class=variable>$out</span> =  @<span class=variable>$resId</span><span class=variable>-&gt;columnCount</span>();</div><div class=line>		} <span class=keyword>catch</span>(PDOException <span class=variable>$e</span>) {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;error</span> = <span class=keyword>true</span>;</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;errorMessage</span> = <span class=variable>$e</span><span class=variable>-&gt;getMessage</span>();</div><div class=line>			<span class=keyword>return</span> <span class=keyword>false</span>; </div><div class=line>		}</div><div class=line>		<span class=keyword>return</span> <span class=variable>$out</span>;		</div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>field_name</span><span class=params>(<span class=variable>$resId</span> = null, <span class=variable>$index</span>)</span> </span>{</div><div class=line>		<span class=keyword>try</span> {</div><div class=line>			<span class=keyword>if</span>(<span class=variable>$resId</span> == <span class=keyword>null</span>) <span class=variable>$resId</span> = <span class=variable>$this</span><span class=variable>-&gt;resId</span>;</div><div class=line>			<span class=keyword>if</span>(DEBUG) <span class=variable>$tempColInfo</span> = <span class=variable>$resId</span><span class=variable>-&gt;getColumnMeta</span>(<span class=variable>$index</span>);</div><div class=line>			<span class=keyword>else</span> <span class=variable>$tempColInfo</span> = @<span class=variable>$resId</span><span class=variable>-&gt;getColumnMeta</span>(<span class=variable>$index</span>);</div><div class=line>		} <span class=keyword>catch</span>(PDOException <span class=variable>$e</span>) {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;error</span> = <span class=keyword>true</span>;</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;errorMessage</span> = <span class=variable>$e</span><span class=variable>-&gt;getMessage</span>();</div><div class=line>			<span class=keyword>return</span> <span class=keyword>false</span>; </div><div class=line>		}	</div><div class=line>		<span class=keyword>return</span> <span class=variable>$tempColInfo</span>[<span class=string>"name"</span>];</div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>create_function</span><span class=params>(<span class=variable>$function_name</span>, <span class=variable>$callback</span>, <span class=variable>$num_arg</span>=null)</span> </span>{</div><div class=line>		<span class=keyword>try</span> {</div><div class=line>			<span class=keyword>if</span>(method_exists(<span class=variable>$this</span><span class=variable>-&gt;connId</span>, <span class=string>'sqliteCreateFunction'</span>)) {</div><div class=line>				<span class=keyword>if</span>(DEBUG) <span class=keyword>return</span> <span class=variable>$this</span><span class=variable>-&gt;connId</span><span class=variable>-&gt;sqliteCreateFunction</span>(<span class=variable>$function_name</span>, <span class=variable>$callback</span>, <span class=variable>$num_arg</span>);</div><div class=line>				<span class=keyword>else</span> <span class=keyword>return</span> @<span class=variable>$this</span><span class=variable>-&gt;connId</span><span class=variable>-&gt;sqliteCreateFunction</span>(<span class=variable>$function_name</span>, <span class=variable>$callback</span>, <span class=variable>$num_arg</span>);</div><div class=line>			} <span class=keyword>else</span> {</div><div class=line>				<span class=keyword>return</span> <span class=keyword>false</span>;</div><div class=line>			}</div><div class=line>		} <span class=keyword>catch</span>(PDOException <span class=variable>$e</span>) {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;error</span> = <span class=keyword>true</span>;</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;errorMessage</span> = <span class=variable>$e</span><span class=variable>-&gt;getMessage</span>();</div><div class=line>			<span class=keyword>return</span> <span class=keyword>false</span>; </div><div class=line>		}</div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>create_aggregate</span><span class=params>(<span class=variable>$function_name</span>, <span class=variable>$step_func</span>, <span class=variable>$finalize_func</span>, <span class=variable>$num_args</span>=null)</span> </span>{</div><div class=line>		<span class=keyword>if</span>(method_exists(<span class=variable>$this</span><span class=variable>-&gt;connId</span>, <span class=string>'sqliteCreateAggregate'</span>)) {</div><div class=line>			<span class=keyword>try</span> {</div><div class=line>				<span class=keyword>if</span>(DEBUG) <span class=keyword>return</span> <span class=variable>$this</span><span class=variable>-&gt;connId</span><span class=variable>-&gt;sqliteCreateAggregate</span>(<span class=variable>$function_name</span>, <span class=variable>$step_func</span>, <span class=variable>$finalize_func</span>, <span class=variable>$num_args</span>);</div><div class=line>				<span class=keyword>else</span> <span class=keyword>return</span> @<span class=variable>$this</span><span class=variable>-&gt;connId</span><span class=variable>-&gt;sqliteCreateAggregate</span>(<span class=variable>$function_name</span>, <span class=variable>$step_func</span>, <span class=variable>$finalize_func</span>, <span class=variable>$num_args</span>);</div><div class=line>			} <span class=keyword>catch</span>(PDOException <span class=variable>$e</span>) {</div><div class=line>				<span class=variable>$this</span><span class=variable>-&gt;error</span> = <span class=keyword>true</span>;</div><div class=line>				<span class=variable>$this</span><span class=variable>-&gt;errorMessage</span> = <span class=variable>$e</span><span class=variable>-&gt;getMessage</span>();</div><div class=line>				<span class=keyword>return</span> <span class=keyword>false</span>; </div><div class=line>			}</div><div class=line>		} <span class=keyword>else</span> {</div><div class=line>			<span class=keyword>return</span> <span class=keyword>false</span>;</div><div class=line>		}</div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>sqlite_version</span><span class=params>()</span> </span>{</div><div class=line>		<span class=keyword>try</span> {</div><div class=line>			<span class=variable>$query</span> = <span class=string>"SELECT sqlite_version();"</span>;</div><div class=line>			<span class=variable>$res</span> = <span class=variable>$this</span><span class=variable>-&gt;query_once</span>(<span class=variable>$query</span>, <span class=keyword>true</span>, <span class=keyword>false</span>);</div><div class=line>			<span class=variable>$Result</span> = <span class=variable>$this</span><span class=variable>-&gt;fetch_single</span>(<span class=variable>$res</span>, SQLITE_NUM);</div><div class=line>			<span class=keyword>if</span>(<span class=variable>$Result</span>) <span class=keyword>return</span> <span class=variable>$Result</span>;</div><div class=line>			<span class=keyword>else</span> <span class=keyword>return</span> <span class=keyword>false</span>;</div><div class=line>		} <span class=keyword>catch</span>(PDOException <span class=variable>$e</span>) {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;error</span> = <span class=keyword>true</span>;</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;errorMessage</span> = <span class=variable>$e</span><span class=variable>-&gt;getMessage</span>();</div><div class=line>			<span class=keyword>return</span> <span class=keyword>false</span>; </div><div class=line>		}</div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>close</span><span class=params>()</span> </span>{</div><div class=line>		<span class=comment>// set obj to null</span></div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>sqlitem_busy_timeout</span><span class=params>(<span class=variable>$milliseconds</span>=<span class=number>0</span>)</span> </span>{</div><div class=line>		<span class=keyword>try</span> {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;connId</span><span class=variable>-&gt;setAttribute</span>(PDO_ATTR_TIMEOUT, <span class=variable>$milliseconds</span>);</div><div class=line>			<span class=keyword>return</span> <span class=keyword>true</span>;</div><div class=line>		} <span class=keyword>catch</span>(PDOException <span class=variable>$e</span>) {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;error</span> = <span class=keyword>true</span>;</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;errorMessage</span> = <span class=variable>$e</span><span class=variable>-&gt;getMessage</span>();</div><div class=line>			<span class=keyword>return</span> <span class=keyword>false</span>; </div><div class=line>		}</div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>convertResultType</span><span class=params>(<span class=variable>$type</span>)</span> </span>{</div><div class=line>		<span class=variable>$fetch_style</span> = PDO_FETCH_BOTH;</div><div class=line>		<span class=keyword>if</span>(<span class=variable>$type</span> == SQLITE_ASSOC) 		<span class=variable>$fetch_style</span> = PDO_FETCH_ASSOC;</div><div class=line>		<span class=keyword>elseif</span>(<span class=variable>$type</span> == SQLITE_NUM) 	<span class=variable>$fetch_style</span> = PDO_FETCH_NUM;</div><div class=line>		<span class=keyword>elseif</span>(<span class=variable>$type</span> == SQLITE_BOTH)  	<span class=variable>$fetch_style</span> = PDO_FETCH_BOTH;	</div><div class=line>		<span class=keyword>return</span> 	<span class=variable>$fetch_style</span>;</div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>beginTransaction</span><span class=params>()</span> </span>{</div><div class=line>		<span class=keyword>try</span> {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;connId</span><span class=variable>-&gt;beginTransaction</span>();</div><div class=line>		} <span class=keyword>catch</span>(PDOException <span class=variable>$e</span>) {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;error</span> = <span class=keyword>true</span>;</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;errorMessage</span> = <span class=variable>$e</span><span class=variable>-&gt;getMessage</span>();</div><div class=line>			<span class=keyword>return</span> <span class=keyword>false</span>; </div><div class=line>		}</div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>commitTransaction</span><span class=params>()</span> </span>{</div><div class=line>		<span class=keyword>try</span> {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;connId</span><span class=variable>-&gt;commit</span>();</div><div class=line>		} <span class=keyword>catch</span>(PDOException <span class=variable>$e</span>) {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;error</span> = <span class=keyword>true</span>;</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;errorMessage</span> = <span class=variable>$e</span><span class=variable>-&gt;getMessage</span>();</div><div class=line>			<span class=keyword>return</span> <span class=keyword>false</span>; </div><div class=line>		}</div><div class=line>	}</div><div class=line></div><div class=line>	<span class=function><span class=keyword>function</span> <span class=title>rollBackTransaction</span><span class=params>()</span> </span>{</div><div class=line>		<span class=keyword>try</span> {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;connId</span><span class=variable>-&gt;rollBack</span>();</div><div class=line>		} <span class=keyword>catch</span>(PDOException <span class=variable>$e</span>) {</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;error</span> = <span class=keyword>true</span>;</div><div class=line>			<span class=variable>$this</span><span class=variable>-&gt;errorMessage</span> = <span class=variable>$e</span><span class=variable>-&gt;getMessage</span>();</div><div class=line>			<span class=keyword>return</span> <span class=keyword>false</span>; </div><div class=line>		}</div><div class=line>	}</div><div class=line>}</div><div class=line><span class=preprocessor>?&gt;</span></div></pre></td></tr></table></figure>
<div class=ujian-hook></div>
</div>
<footer class=article-footer>
<div class=bdsharebuttonbox>
<a href=# class=bds_tsina data-cmd=tsina title=分享到新浪微博></a>
<a href=# class=bds_qzone data-cmd=qzone title=分享到QQ空间></a>
<a href=# class=bds_tqq data-cmd=tqq title=分享到腾讯微博></a>
<a href=# class=bds_weixin data-cmd=weixin title=分享到微信></a>
<a href=# class=bds_tieba data-cmd=tieba title=分享到百度贴吧></a>
<a href=# class=bds_renren data-cmd=renren title=分享到人人网></a>
<a href=# class=bds_tqf data-cmd=tqf title=分享到腾讯朋友></a>
<a href=# class=bds_douban data-cmd=douban title=分享到豆瓣网></a>
<a href=# class=bds_tsohu data-cmd=tsohu title=分享到搜狐微博></a>
<a href=# class=bds_t163 data-cmd=t163 title=分享到网易微博></a>
<a href=# class=bds_taobao data-cmd=taobao title=分享到我的淘宝></a>
<a href=# class=bds_fx data-cmd=fx title=分享到飞信></a>
<a href=# class=bds_hi data-cmd=hi title=分享到百度空间></a>
<a href=# class=bds_more data-cmd=more></a>
</div>
<ul class=article-tag-list><li class=article-tag-list-item><a class=article-tag-list-link href=../tag/pdo>PDO</a></li><li class=article-tag-list-item><a class=article-tag-list-link href=../tag/php>PHP</a></li><li class=article-tag-list-item><a class=article-tag-list-link href=../tag/sqlite>SQLite</a></li><li class=article-tag-list-item><a class=article-tag-list-link href=../tag/数据库>数据库</a></li><li class=article-tag-list-item><a class=article-tag-list-link href=../tag/程序设计>程序设计</a></li><li class=article-tag-list-item><a class=article-tag-list-link href=../tag/编程>编程</a></li><li class=article-tag-list-item><a class=article-tag-list-link href=../tag/计算机>计算机</a></li></ul>
</footer>
</div>
<nav id=article-nav>
<a href="/rebuild-blog/" id=article-nav-newer class=article-nav-link-wrap>
<strong class=article-nav-caption>Newer</strong>
<div class=article-nav-title>
重新建立我的博客
</div>
</a>
<a href="/hefei-acm-trip/" id=article-nav-older class=article-nav-link-wrap>
<strong class=article-nav-caption>Older</strong>
<div class=article-nav-title>合肥ACM之旅</div>
</a>
</nav>
</article>
<section id=comments>
<div class=ds-thread data-thread-key="php-sqlite3-class/" data-title=整理修改了一个PHP的SQLite3数据库类 data-url="http://cweili.gitcafe.com/php-sqlite3-class/"></div>
</section>
</section>
<aside id=sidebar class=col-sm-3>
<div class="widget-wrap hidden-xs">
<h3 class=widget-title>分类</h3>
<div class=widget>
<ul class=category-list><li class=category-list-item><a class=category-list-link href=../category/学习笔记>学习笔记</a><span class=category-list-count>40</span></li><li class=category-list-item><a class=category-list-link href=../category/小生活>小生活</a><span class=category-list-count>27</span></li><li class=category-list-item><a class=category-list-link href=../category/杂物>杂物</a><span class=category-list-count>9</span></li></ul>
</div>
</div>
<div class=widget-wrap>
<h3 class=widget-title>最新评论</h3>
<div class=widget>
<div class=ds-recent-comments data-num-items=10 data-show-avatars=1 data-show-time=1 data-show-title=0 data-show-admin=1 data-excerpt-length=20>
<div class=text-center><i class="fa fa-refresh fa-spin"></i></div>
</div>
</div>
</div>
<div class=widget-wrap>
<h3 class=widget-title>最新文章</h3>
<div class=widget>
<ul>
<li>
<a href="/xixishidi/">河塘飞鸟西溪湿地</a>
</li>
<li>
<a href="/xizihu/">水光潋滟西子湖畔</a>
</li>
<li>
<a href="/xitang/">柳絮纷飞烟雨西塘</a>
</li>
<li>
<a href="/wuzhen/">灯火阑珊水映乌镇</a>
</li>
<li>
<a href="/stu3-zoo/">Stu3 Zoo</a>
</li>
<li>
<a href="/jshint-options/">JSHint配置参数详解</a>
</li>
<li>
<a href="/css3-jquery-rocket-to-top/">CSS3动画与jQuery实现返回顶部小火箭</a>
</li>
<li>
<a href="/rebuild-blog-gitcafe/">再一次重建我的博客</a>
</li>
<li>
<a href="/java-poi-excel/">Java使用POI创建Excel图表</a>
</li>
<li>
<a href="/hibernate-connect-sqlite-paging-bug-repair/">Hibernate 连接 SQLite (hibernate-sqlite) 分页bug的修复</a>
</li>
<li>
<a href="/web-page-color-chart/">更全的网页颜色表</a>
</li>
<li>
<a href="/quarrying-rocky-4/">20120407春游采石矶(四)</a>
</li>
<li>
<a href="/quarrying-rocky-3/">20120407春游采石矶(三)</a>
</li>
<li>
<a href="/quarrying-rocky-2/">20120407春游采石矶(二)</a>
</li>
<li>
<a href="/quarrying-rocky/">20120407春游采石矶(一)</a>
</li>
<li>
<a href="/ahpu-spring/">安徽工程大学的春天</a>
</li>
<li>
<a href="/helps-students-assembled-computer/">帮同学组装帅气小机箱电脑一台</a>
</li>
<li>
<a href="/nanjing-trip-4/">20120310南京二日行(四)</a>
</li>
<li>
<a href="/nanjing-trip-3/">20120310南京二日行(三)</a>
</li>
<li>
<a href="/nanjing-trip-2/">20120310南京二日行(二)</a>
</li>
</ul>
</div>
</div>
<div class="widget-wrap hidden-xs">
<h3 class=widget-title>手机阅读</h3>
<div class=widget>
<div class=qrcode style="background-image:url(http://qr.liantu.com/api.php?bg=eeeeee&fg=000000&el=l&w=192&m=0&text=http://cweili.gitcafe.com/php-sqlite3-class/)"></div>
</div>
</div>
<div class="widget-wrap hidden-xs">
<h3 class=widget-title>标签云</h3>
<div class="widget tagcloud">
<a href=../tag/acm style=font-size:10px>ACM</a><a href=../tag/c++ style=font-size:15.71px>C++</a><a href=../tag/css style=font-size:10px>CSS</a><a href=../tag/fedora style=font-size:15.71px>Fedora</a><a href=../tag/gnome style=font-size:11.43px>Gnome</a><a href=../tag/hibernate style=font-size:10px>Hibernate</a><a href=../tag/jshint style=font-size:10px>JSHint</a><a href=../tag/java style=font-size:11.43px>Java</a><a href=../tag/javascript style=font-size:12.86px>JavaScript</a><a href=../tag/linux style=font-size:17.14px>Linux</a><a href=../tag/pdo style=font-size:10px>PDO</a><a href=../tag/php style=font-size:12.86px>PHP</a><a href=../tag/poi style=font-size:10px>POI</a><a href=../tag/photoshop style=font-size:14.29px>Photoshop</a><a href=../tag/sae style=font-size:10px>SAE</a><a href=../tag/sql style=font-size:14.29px>SQL</a><a href=../tag/sqlite style=font-size:11.43px>SQLite</a><a href=../tag/stl style=font-size:11.43px>STL</a><a href=../tag/stu3 style=font-size:10px>Stu3</a><a href=../tag/twitter style=font-size:10px>Twitter</a><a href=../tag/virtualbox style=font-size:10px>VirtualBox</a><a href=../tag/jquery style=font-size:10px>jQuery</a><a href=../tag/三国杀 style=font-size:15.71px>三国杀</a><a href=../tag/乌镇 style=font-size:10px>乌镇</a><a href=../tag/互联网 style=font-size:10px>互联网</a><a href=../tag/动漫 style=font-size:11.43px>动漫</a><a href=../tag/动画 style=font-size:10px>动画</a><a href=../tag/南京 style=font-size:14.29px>南京</a><a href=../tag/博客 style=font-size:14.29px>博客</a><a href=../tag/实验 style=font-size:15.71px>实验</a><a href=../tag/容器 style=font-size:11.43px>容器</a><a href=../tag/小说 style=font-size:10px>小说</a><a href=../tag/微博 style=font-size:11.43px>微博</a><a href=../tag/心情 style=font-size:14.29px>心情</a><a href=../tag/摄影 style=font-size:17.14px>摄影</a><a href=../tag/操作系统 style=font-size:14.29px>操作系统</a><a href=../tag/数据库 style=font-size:18.57px>数据库</a><a href=../tag/旅行 style=font-size:20px>旅行</a><a href=../tag/日记 style=font-size:17.14px>日记</a><a href=../tag/杭州 style=font-size:11.43px>杭州</a>
</div>
</div>
<div class="widget-wrap hidden-xs">
<h3 class=widget-title>归档</h3>
<div class=widget>
<ul class=archive-list><li class=archive-list-item><a class=archive-list-link href=../archive/2014/09>September 2014</a><span class=archive-list-count>4</span></li><li class=archive-list-item><a class=archive-list-link href=../archive/2014/08>August 2014</a><span class=archive-list-count>4</span></li><li class=archive-list-item><a class=archive-list-link href=../archive/2012/09>September 2012</a><span class=archive-list-count>1</span></li><li class=archive-list-item><a class=archive-list-link href=../archive/2012/05>May 2012</a><span class=archive-list-count>2</span></li><li class=archive-list-item><a class=archive-list-link href=../archive/2012/04>April 2012</a><span class=archive-list-count>5</span></li><li class=archive-list-item><a class=archive-list-link href=../archive/2012/03>March 2012</a><span class=archive-list-count>5</span></li><li class=archive-list-item><a class=archive-list-link href=../archive/2011/12>December 2011</a><span class=archive-list-count>4</span></li><li class=archive-list-item><a class=archive-list-link href=../archive/2011/11>November 2011</a><span class=archive-list-count>18</span></li><li class=archive-list-item><a class=archive-list-link href=../archive/2011/10>October 2011</a><span class=archive-list-count>32</span></li><li class=archive-list-item><a class=archive-list-link href=../archive/2011/05>May 2011</a><span class=archive-list-count>2</span></li></ul>
</div>
</div>
<div class="widget-wrap hidden-xs">
<h3 class=widget-title>友情链接</h3>
<div class=widget>
<ul>
<li>
<a href=http://cweili.gitcafe.com target=_blank>主页</a>
</li>
</ul>
</div>
</div>
</aside>
</div>
<footer id=footer>
<div class=footer-wrap>
<div class=outer>
<div class=inner>
<div id=social-network>
<a class=link href=https://github.com/Cweili target=_blank><i class="fa fa-fw fa-github"></i></a>
<a class=link href=http://weibo.com/cweili target=_blank><i class="fa fa-fw fa-weibo"></i></a>
</div>
<div id=footer-info>
&copy; 2014 <a href=http://cweili.gitcafe.com target=_blank>Cweili</a><br>
Powered by <a href="http://hexo.io/" target=_blank>Hexo</a>.
Theme by <a href=http://cweili.gitcafe.com target=_blank>Cweili</a>.
</div>
</div>
</div>
</div>
</footer>
</div>
</div>
<div id=rocket-to-top>
<div class=onhover></div>
<div class=anim></div>
</div>
<link rel=stylesheet href=//libs.baidu.com/fontawesome/4.0.3/css/font-awesome.min.css css type=text/css>
<script src=//libs.baidu.com/jquery/1.11.1/jquery.min.js type=text/javascript></script><link rel=stylesheet href=//cdn.staticfile.org/fancybox/2.1.5/jquery.fancybox.min.css type=text/css>
<script src=//cdn.staticfile.org/fancybox/2.1.5/jquery.fancybox.min.js type=text/javascript></script><script src=../js/script.js type=text/javascript></script><script type=text/javascript>var duoshuoQuery={short_name:"cweiligitcafe"};</script><script src=//static.duoshuo.com/embed.js type=text/javascript></script><script type=text/javascript>var ujian_config={num:10,showType:3};</script><script src="http://v1.ujian.cc/code/ujian.js?uid=1539214&_=.js" type=text/javascript></script><script type=text/javascript>window._bd_share_config={common:{bdSnsKey:{},bdPopTitle:"分享到",bdMini:2,bdPopupOffsetLeft:28,bdPopupOffsetTop:108,bdMiniList:["sqq","mshare","bdysc","kaixin001","ibaidu","baidu","ff","qy","meilishuo","mogujie","diandian","ty","youdao","sdo"],bdPic:"",bdStyle:1,bdSize:"24"},share:{},image:{viewList:["tsina","qzone","tqq","weixin","tieba","renren","tqf","douban","tsohu","t163","taobao","fx","hi"],viewText:" ",viewSize:"24"},selectShare:{bdContainerClass:"article",bdSelectMiniList:["tsina","qzone","tqq","weixin","tieba","renren","tqf","douban","tsohu","t163","taobao","fx","hi"]}},document.write('<script type="text/javascript" src="http://bdimg.share.baidu.com/static/api/js/share.js?cdnversion='+~(-new Date/36e5)+'"><\/script>');</script><div id=stat-wrap>
<script src="http://s19.cnzz.com/stat.php?id=1252976445&web_id=1252976445" type=text/javascript></script></div></body></html>